package com.l2jserver.gameserver.taskmanager.tasks;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.gameserver.taskmanager.Task;
import com.l2jserver.gameserver.taskmanager.TaskManager;
import com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask;
import com.l2jserver.gameserver.taskmanager.TaskTypes;

/**
 * Reset del tiempo de caza del sistema nevit
 * @author fissban
 */
public class TaskNevit extends Task
{
	private static final Logger _log = Logger.getLogger(TaskRecom.class.getName());
	private static final String NAME = "nevit_system";
	
	@Override
	public String getName()
	{
		return NAME;
	}
	
	@Override
	public void onTimeElapsed(ExecutedTask task)
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("UPDATE characters SET nevit_time=?"))
		{
			statement.setInt(1, 0); // time = 4hs
			statement.execute();
		}
		catch (Exception e)
		{
			_log.log(Level.SEVERE, "Could not reset character nevit timer System: " + e);
		}
		_log.config("Character Nevit Timer Reseted.");
	}
	
	@Override
	public void initializate()
	{
		super.initializate();
		TaskManager.addUniqueTask("nevit_system", TaskTypes.TYPE_GLOBAL_TASK, "1", "06:30:00", "");
	}
}
